//package com.cqrcb.cloud.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.stream.Consumer;
//import org.springframework.data.redis.connection.stream.ReadOffset;
//import org.springframework.data.redis.connection.stream.StreamOffset;
//import org.springframework.data.redis.stream.StreamMessageListenerContainer;
//import org.springframework.data.redis.stream.Subscription;
//
//import java.time.Duration;
//
///**
// * @author Huhailong
// * @Description
// * @Date 2021/3/12.
// */
//@Configuration
//public class RedisStreamConfig {
//
//    @Autowired
//    private ListenerMessage streamListener;
//
//    @Bean
//    public Subscription subscription(RedisConnectionFactory factory){
//        StreamMessageListenerContainer.StreamMessageListenerContainerOptions options = StreamMessageListenerContainer
//                .StreamMessageListenerContainerOptions
//                .builder()
//                .pollTimeout(Duration.ofSeconds(1))
//                .build();
//        StreamMessageListenerContainer listenerContainer = StreamMessageListenerContainer.create(factory,options);
//        Subscription subscription = listenerContainer.receive(Consumer.from("mqGroup","consumerC"),
//                StreamOffset.create("mq", ReadOffset.lastConsumed()),streamListener);
//        listenerContainer.start();
//        return subscription;
//    }
//}
